import 'package:flutter_oldman_health/models/response_data_model.dart';

class HealthDataModel extends ResponseDataModel<HealthData> {
  factory HealthDataModel.fromJson(Map<String, dynamic> json) {
    return HealthDataModel(
        code: json["code"],
        data: HealthData.fromJson(json['data']),
        msg: json["msg"]);
  }

  HealthDataModel({int code, HealthData data, String msg})
      : super(code: code, data: data, msg: msg);
}

class HealthData {
  HealthItemData bloodOxygen;
  HealthItemData heartRate;
  HealthItemData temperature;

  HealthData({this.bloodOxygen, this.heartRate, this.temperature});

  factory HealthData.fromJson(Map<String, dynamic> json) {
    return HealthData(
      bloodOxygen: HealthItemData.fromJson(json['bloodOxygen']),
      heartRate: HealthItemData.fromJson(json['heartRate']),
      temperature: HealthItemData.fromJson(json['temperature']),
    );
  }
}

class HealthListModel extends ResponseDataModel<List<HealthItemData>> {
  HealthListModel({int code, List<HealthItemData> data, String msg})
      : super(code: code, data: data, msg: msg);

  factory HealthListModel.fromJson(Map<String, dynamic> json) {
    var healthData = json["data"] as List;
    print(healthData);
    return HealthListModel(
        code: json["code"],
        data: healthData.map((e) => HealthItemData.fromJson(e)).toList(),
        msg: json["msg"]);
  }
}

class HealthItemData {
// "date" : 1599364578162,
// "value" : 96

  int date;
  num value;

  factory HealthItemData.fromJson(Map<String, dynamic> json) {
    if (null == json) {
      return null;
    }
    return HealthItemData(date: json["date"], value: json["value"]);
  }

  HealthItemData({this.date, this.value});
}
class HealthAverageListModel extends ResponseDataModel<List<HealthAverageData>> {
  HealthAverageListModel({int code, List<HealthAverageData> data, String msg})
      : super(code: code, data: data, msg: msg);

  factory HealthAverageListModel.fromJson(Map<String, dynamic> json) {
    var healthData = json["data"] as List;
    print(healthData);
    return HealthAverageListModel(
        code: json["code"],
        data: healthData.map((e) => HealthAverageData.fromJson(e)).toList(),
        msg: json["msg"]);
  }
}
class HealthAverageData {
  int inDate;
  double average;
  double min;
  double max;
  double sum;

  factory HealthAverageData.fromJson(Map<String, dynamic> json) {
    if (null == json) {
      return null;
    }
    return HealthAverageData(
        inDate: json["inDate"], average: json["average"],
        min: json["min"], max: json["max"], sum: json["sum"]);
  }

  HealthAverageData({this.inDate, this.average,this.min, this.max,this.sum});
}
